package com.wangy.controller;

import com.wangy.bean.Page;
import com.wangy.bean.TrafficStatistic;
import com.wangy.service.StatisticService;
import com.wangy.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;

/**
 * @author yyzb
 * @date 2024/12/29 19:11
 */

@RestController
@RequestMapping("/statistic/visit")
public class TrafficController {

    @Autowired
    StatisticService statisticService;

    @GetMapping("getTrafficStats/{page}/{limit}")
    public Result<Page<TrafficStatistic>> getTrafficStats(@PathVariable Integer page, @PathVariable Integer limit, TrafficStatistic trafficStatistic) {
        Page<TrafficStatistic> trafficStatistics = statisticService.getTrafficStatistics(page, limit, trafficStatistic.getDt(), trafficStatistic.getRecentDays());
        return Result.of(200, "success", trafficStatistics);
    }

    /**
     * 用户路径分析
     */
    @GetMapping("getPagePath")
    public Result<Map<String, Object>> getPagePath(TrafficStatistic trafficStatistic) {
        return Result.of(200, "success", statisticService.getPagePathCount(trafficStatistic));
    }
}
